package com.imooc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.imooc.rabbitmq.MqSender;
import com.imooc.result.Result;

@Controller
@RequestMapping("/mq")
public class MqController {
	
	@Autowired
	MqSender mqSender;
	
	@RequestMapping("/send")
	@ResponseBody
	public Result send(){
		mqSender.sender("hello albin");
		return Result.success("发送成功");
	}
	
	/**
	 * TOPIC模式 - 交换机
	 * @return
	 */
	@RequestMapping("/sendTopic")
	@ResponseBody
	public Result sendTopic(){
		mqSender.senderTopic("hello topic");
		return Result.success("发送成功");
	}
	
	/**
	 * FANOUT 广播模式 - 交换机
	 * @return
	 */
	@RequestMapping("/sendFanout")
	@ResponseBody
	public Result sendFanout(){
		mqSender.senderFanout("hello fanout");
		return Result.success("发送成功");
	}
	
	/**
	 * HEADER 模式 - 交换机
	 * @return
	 */
	@RequestMapping("/sendHeader")
	@ResponseBody
	public Result sendHeader(){
		mqSender.senderHeader("hello header");
		return Result.success("发送成功");
	}
	

}
